#include "iostream"
#include "string"
#include "algorithm"
#include "vector"

using namespace std;

int main()
{
    string s, t;
    while (cin >> s >> t)
    {
        int n = s.length();
        vector<int> ss(26), tt(26);
        for (int i = 0; i < n; ++i) {
            ss[s[i] - 'A']++;
            tt[t[i] - 'A']++;
        }
        sort(ss.begin(), ss.end());
        sort(tt.begin(), tt.end());
        int f = 1;
        for (int i = 0; i < 26; ++i) {
            if(ss[i] != tt[i])
            {
                f = 0;
                printf("NO\n");
                break;
            }
        }
        if(f)
            printf("YES\n");
    }
    return 0;
}